import { getValidateMessage } from "@/utils/validate-rules/message";
import { UploadOutlined } from "@ant-design/icons";
import { Button } from "antd";
import React from "react";

export interface ExportFileProps {
    url: string;
    onClick?: () => any;
    [propsName: string]: any
}

const ExportFile: React.FC<ExportFileProps> = ({ url, onClick, ...exraProps }) => {
    const handleClick = () => {
        if (onClick) {
            onClick();
        } else {
            window.open(url);
        }
    }
    return <Button icon={<UploadOutlined />} {...exraProps} onClick={handleClick}>{getValidateMessage('common.export', true)}</Button>;
}

export default ExportFile;